"""问答功能的请求/响应数据模型"""
from pydantic import BaseModel, Field
from typing import List, Optional


class QuestionRequest(BaseModel):
    """用户问答请求参数"""
    question: str = Field(..., description="用户的问题文本")
    top_k: Optional[int] = Field(3, ge=1, le=10, description="检索相关文档的数量（1-10）")


class AnswerResponse(BaseModel):
    """问答接口返回结果"""
    answer: str = Field(..., description="基于知识库的回答")
    related_docs: List[str] = Field(..., description="用于生成回答的相关文档片段")
    success: bool = Field(True, description="请求处理是否成功")